package cn.ittaoli.movie.controller;

import cn.ittaoli.movie.model.Slide;
import cn.ittaoli.movie.service.SlideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by lub_lenovo on 2017/11/6.
 */
@Controller
@RequestMapping("/slide")
public class SlideController {
    @Autowired
    private SlideService slideService;

    @RequestMapping("/add")
    public String add(){
        return "/admin/slide_add";
    }

    @RequestMapping("/doAdd")
    @ResponseBody
    public Integer doAdd(Slide slide){
        return slideService.insert(slide);
    }


    @RequestMapping("/list")
    public String list(Model model){
        List<Slide> slideList=slideService.getAll();
        model.addAttribute("slide",slideList);
        return "/admin/slide_list";
    }

}
